home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: Re: How can I include IOSTREAM.H only once?
- Date: 26 Feb 1996 22:29:29 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4gtc89$b88@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe10.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Feb 26, 1996 04:51:44 in article <How can I include IOSTREAM.H only
- once?>, 'bluefox@info.polymtl.ca (Michael Gaudette)' wrote:
-
-
- >I am presently engaged in what is usually called "the learning process",
- >and I've been programming simple programs with classes. Because of this,
-
- >I have had to #include <iostream.h> in most of my "class.cpp" files AND
- >in my main program. This (added to conio.h and all the other standard
- >libraries) usually result in a simple program being 20000 lines long.
- >Is there any way (using Borland v4.5) to make the compiler only link
- >those files ONCE?
- >
- Yes and no.
-
- First the no. The compiler must be able to "see" all the prototypes
- in the header files, therefore, the files must be included in each
- source file that uses funtions in those headers. Of course,
- if you only need one or two prototypes from each file, you
- could just copy those into our own header, but that's really
- not recommended.
-
- Now, the yes. Precompiling headers goes a long way to ease
- the pain. To take maximum advantage of header file pre-
- compiling, you need the include the standard set in the same
- sequence in every file. One way is to create a file incl.h
- into which you place all the standard library header your
- project uses, then include that file as the first file in all
- of your source files. Then, use a pragma hdrstop to further
- enhance precompilation. Read details in online docs
- under the topic "precompiled headers".
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-